<template>
	<view class="main">
		<view class="list">
			<view class="border a">
				<view class="left">
					转账方式
				</view>
				<view class="right" @click="styleShow = true">
					{{style || '请选择转账方式'}}
				</view>
			</view>
			<!-- <view class="border a">
				<view class="left">
					转账类型
				</view>
				<view class="right" @click="typeShow = true">
					{{type || '请选择转账类型'}}
				</view>
			</view> -->
			<view class="border a">
				<view class="left">
					转入账号
				</view>
				<view class="right">
					<input v-model="tousername" type="text" placeholder="请输入转入账号" />
				</view>
			</view>
			<view class="border a">
				<view class="left">
					金额
				</view>
				<view class="right">
					<input v-model="money" type="number" placeholder="0.00" />
				</view>
			</view>
			<!-- <view class="border a">
				<view class="left">
					转入数量
				</view>
				<view class="right">
					<input v-model="money" type="number" placeholder="请输入积分数量" />
				</view>
			</view> -->
			<!-- <view class="border a">
				<view class="left">
					手续费%
				</view>
				<view class="right">
					<input v-model="money" type="number" placeholder="0" />
				</view>
			</view> -->
			<!-- <view class="border a">
				<view class="left">
					支付密码
				</view>
				<view class="right">
					<input v-model="money" type="number" placeholder="请输入支付密码" />
				</view>
			</view> -->
		</view>
		<view class="btn" @tap="confirm">
			提交
		</view>
		
		<u-picker :show="typeShow" :columns="typeLists" keyName="title" @cancel="typeShow = false" @close="typeShow = false" @confirm="handleType"></u-picker>
		
		<u-picker :show="styleShow" :columns="styleLists" keyName="title" @cancel="styleShow = false" @close="styleShow = false" @confirm="handleStyle"></u-picker>
		<u-modal confirmColor="#000" :show="show" :title="title" @confirm="chat" :closeOnClickOverlay="true"
			@close="show = false">
			<view class="slot-content">
				<input v-model="psd2" placeholder="请输入二级密码" type="password" value="" />
			</view>
		</u-modal>
	</view>
</template>

<script>
	import {
		send,
		changePwd,
		checkpwd2,
		user,
		moneychangeTfReply
	} from'@/api/index.js'
	export default{
		data(){
			return{
				typeShow: false,
				typeLists: [[
					{
						id: 1,
						title: '转给其他会员'
					}
				]],
				type:'',
				styleShow: false,
				styleLists: [[
					{
						id: 2,
						title: '红积分到红积分'
					},
					{
						id: 3,
						title: '云积分到云积分'
					}
				]],
				style:'',
				moneytype: '',
				tousername: '',
				money: '',
				show: false,
				ispsd2: "",
				title: '验证二级密码',
				psd2: '',
			}
		},
		onShow() {
			user().then(res => {
				this.ispsd2 = res.data.is_password2
			})
		},
		methods:{
			async confirm(){
				if(!this.style){
					uni.showToast({
						title:'请选择转账方式',
						icon:"none"
					})
					return
				}
				// if(!this.type){
				// 	uni.showToast({
				// 		title:'请选择转账类型',
				// 		icon:"none"
				// 	})
				// 	return
				// }
				if(!this.tousername){
					uni.showToast({
						title:'转入账号不能为空',
						icon:"none"
					})
					return
				}
				if(!this.money){
					uni.showToast({
						title:'金额不能为空',
						icon:"none"
					})
					return
				}
				// if(!this.type){
				// 	uni.showToast({
				// 		title:'请输入转入数量',
				// 		icon:"none"
				// 	})
				// 	return
				// }
				// if(!this.type){
				// 	uni.showToast({
				// 		title:'请输入手续费',
				// 		icon:"none"
				// 	})
				// 	return
				// }
				// if(!this.type){
				// 	uni.showToast({
				// 		title:'请输入支付密码',
				// 		icon:"none"
				// 	})
				// 	return
				// }
				if (this.ispsd2 == 1) {
					this.show = true
				} else {
					uni.showToast({
						title: '请先设置二级密码',
						icon: 'none'
					})
					setTimeout(() => {
						uni.navigateTo({
							url: '/pageB/psd2'
						})
					}, 1000)
				}
				
			},
			async chat() {
				if (!this.psd2) {
					uni.showToast({
						title: '请输入二级密码',
						icon: 'none'
					})
					return
				}
				let res = await checkpwd2({
					password: this.psd2
				})
				if (res.code == 1) {
					let res = await moneychangeTfReply({
						moneytype: this.moneytype,
						money:this.money,
						tousername:this.tousername
					})
					if(res.code == 1){
						uni.showToast({
							title:'提交成功',
							icon:"none"
						})
						this.show = true
						setTimeout(()=>{
							uni.navigateBack()
						},1000)
					}else{
						uni.showToast({
							title:res.msg,
							icon:"none"
						})
					}
					this.show = false
				} else {
					uni.showToast({
						title: res.msg,
						icon: 'none'
					})
				}
			},
			handleType (e) {
				this.type = e.value[0].title
				this.typeShow = false
			},
			handleStyle (e) {
				this.style = e.value[0].title
				this.moneytype = e.value[0].id
				this.styleShow = false
			}
		}
	}
</script>

<style lang="scss" scoped>
	.main{
		min-height: 100vh;
		padding: 24rpx;
		color: #000;
		.list{
			.border{
				padding-bottom: 30rpx;
				border-bottom: 2rpx solid #999;
				margin-bottom: 30rpx;
			}
			.a{
				display: flex;
				align-items: center;
				.left{
					width: 25%;
					// font-size: 24rpx;
				}
				.right{
					flex: 1;
					// font-size: 24rpx;
				}
			}
			.b{
				display: flex;
				align-items: center;
				.left{
					width: 25%;
					font-size: 24rpx;
				}
				.right{
					width: 75%;
					font-size: 24rpx;
					display: flex;
					align-items: center;
					input{
						flex: 1;
					}
					.codeBtn {
						padding: 10rpx 14rpx;
						background-color: #ea504f;
						color: #fff;
						font-size: 24rpx;
						border-radius: 8rpx;
						margin-left: 6rpx;
						display: flex;
						align-items: center;
					
						::v-deep.u-count-down__text {
							color: #000;
							font-size: 24rpx;
							line-height: 0;
						}
					}
				}
			}
			.c{
				.left{
					font-size: 28rpx;
					margin-bottom: 40rpx;
				}
				.idList{
					.idItem{
						padding: 16rpx 26rpx;
						border: 2rpx solid #000;
						border-radius: 14rpx;
						display: flex;
						justify-content: space-between;
						align-items: center;
						text{
							color: #666;
							font-size: 24rpx;
						}
						.radio{
							display: flex;
							align-items: center;
							image{
								width: 34rpx;
								height: 34rpx;
							}
						}
					}
				}
			}
		}
		.btn{
			width: 100%;
			padding: 30rpx;
			text-align: center;
			color: #fff;
			background-color: #ea504f;
			border-radius: 10rpx;
		}
	}
</style>